package com.jdk.demo.thread.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

public class TestLockInterruptibly {

	public void test3() throws Exception {
        final ReentrantLock lock = new ReentrantLock();
        lock.lock();

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    // lock.lockInterruptibly();
                    lock.lock();
                } catch(Exception e) {
                    System.out.println(Thread.currentThread().getName() + " interrupted.");
                }
                System.out.println("start child thread -1");
            }
        }, "child thread -1");

        t1.start();
        Thread.sleep(1000);

        t1.interrupt();

        Thread.sleep(1000000);
    }

    public static void main(String[] args) throws Exception {
        new TestLockInterruptibly().test3();
    }

}
